type Fish = { swim: () => void };
type Bird = { fly: () => void };

function move(animal: Fish | Bird) {
    if ('swim' in animal) {
        // animal is type of `Fish` 
        animal.swim();
    } else {
        // here, animal is type of `Brid`
        animal.fly();
    }
}

export {};